﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace TheTVDB
{
    [Flags]
    public enum MirrorType
    {
        Xml = 1,
        Banner = 2,
        Zip = 4
    }

    public class Mirror
    {

        
        public int ID { get; set; }
        public string Path { get; set; }
        public MirrorType Type { get; set; }

        public Mirror()
        {

        }


        public static Mirror FromXml(XmlNode mirrorNode)
        {
            Mirror newMirror = new Mirror();
            foreach (XmlElement child in mirrorNode.ChildNodes)
            {
                
                switch (child.Name)
                {
                    case "id":
                        newMirror.ID = Int32.Parse(child.InnerText);
                        break;
                    case "mirrorpath":
                        newMirror.Path = child.InnerText;
                        break;
                    case "typemask":
                        newMirror.Type = (MirrorType)Int32.Parse(child.InnerText);
                        break;

                    default:
                        break;
                }
            }


            return newMirror;
        }

    }
}
